﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR84Response", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR84Response))]
    public class RR84ResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR84Response clazz;
        
        public RR84ResponseSerializer(IRR84Response clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("XTeeVeaTeade");
            if (clazz.XTeeVeaTeade!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.XTeeVeaTeade))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : XTeeVeaTeade");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("IsikuEesnimi");
            if (clazz.IsikuEesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuEesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikuEesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("IsikuPerenimi");
            if (clazz.IsikuPerenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuPerenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikuPerenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("IsikuSugu");
            if (clazz.IsikuSugu!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuSugu))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikuSugu");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("IsikuSynniaeg");
            if (clazz.IsikuSynniaeg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuSynniaeg))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikuSynniaeg");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("IsikuStaatus");
            if (clazz.IsikuStaatus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuStaatus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikuStaatus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("IsikuElukoht");
            if (clazz.IsikuElukoht!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuElukoht))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikuElukoht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veakood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Veakood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veatekst");
            if (clazz.Veatekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veatekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veatekst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Suhe");
            if (clazz.Suhe!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute(">>>RR84Response>Suhe>Suhe", "http://producers.rr.xtee.riik.ee/producer/rr", clazz.Suhe.Count);
                for (int x = 0; ((clazz.Suhe != null) 
                            && (x < clazz.Suhe.Count)); x = (x + 1)) {
                    if (clazz.Suhe[x]!=null) {
                        Writer.WriteStartElement("Suhe");
                        global::Xtee.Core.SerializationMetadata metaSuhe = this.GetMetaData(clazz.Suhe[x]);
                        Writer.WriteTypeAttribute(metaSuhe.TypeQualifiedName.Namespace, metaSuhe.TypeQualifiedName.Name);
                        metaSuhe.NewSerializer(clazz.Suhe[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Suhe");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="XTeeVeaTeade") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>XTeeVeaTeade");
                }
                clazz.XTeeVeaTeade = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("XTeeVeaTeade")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>XTeeVeaTeade", Reader.LocalName);
            }
            if (Reader.LocalName=="IsikuEesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>IsikuEesnimi");
                }
                clazz.IsikuEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("IsikuEesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>IsikuEesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="IsikuPerenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>IsikuPerenimi");
                }
                clazz.IsikuPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("IsikuPerenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>IsikuPerenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="IsikuSugu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>IsikuSugu");
                }
                clazz.IsikuSugu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("IsikuSugu")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>IsikuSugu", Reader.LocalName);
            }
            if (Reader.LocalName=="IsikuSynniaeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>IsikuSynniaeg");
                }
                clazz.IsikuSynniaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("IsikuSynniaeg")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>IsikuSynniaeg", Reader.LocalName);
            }
            if (Reader.LocalName=="IsikuStaatus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>IsikuStaatus");
                }
                clazz.IsikuStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("IsikuStaatus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>IsikuStaatus", Reader.LocalName);
            }
            if (Reader.LocalName=="IsikuElukoht") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>IsikuElukoht");
                }
                clazz.IsikuElukoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("IsikuElukoht")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>IsikuElukoht", Reader.LocalName);
            }
            if (Reader.LocalName=="Veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>Veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("Veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>Veakood", Reader.LocalName);
            }
            if (Reader.LocalName=="Veatekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>Veatekst");
                }
                clazz.Veatekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Veatekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>Veatekst", Reader.LocalName);
            }
            if (Reader.LocalName=="Suhe") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR84Response>Suhe");
                }
                clazz.Suhe = new System.Collections.Generic.List<RR84Response.ISuheType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("Suhe");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "Suhe")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>RR84Response>Suhe>Suhe");
                        }
                        global::Xtee.Core.SerializationMetadata metaSuhe = this.GetMetaData<RR84Response.ISuheType>(Reader, ">>>RR84Response>Suhe>Suhe", "http://producers.rr.xtee.riik.ee/producer/rr");
                        RR84Response.ISuheType item = metaSuhe.NewEntity<RR84Response.ISuheType>();
                        clazz.Suhe.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("Suhe");
                            metaSuhe.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR84Response>Suhe", Reader.LocalName);
            }
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>RR84Response>Suhe>Suhe", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR84Response.SuheType))]
        public class SuheTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected RR84Response.ISuheType clazz;
            
            public SuheTypeSerializer(RR84Response.ISuheType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("Suhe.Suhtetyyp");
                if (clazz.SuheSuhtetyyp!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheSuhtetyyp))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheSuhtetyyp");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("Suhe.sIsikukood");
                if (clazz.SuhesIsikukood!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesIsikukood))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesIsikukood");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("Suhe.sPerenimi");
                if (clazz.SuhesPerenimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesPerenimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesPerenimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("Suhe.sEesnimi");
                if (clazz.SuhesEesnimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesEesnimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesEesnimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("Suhe.sIsikuElukoht");
                if (clazz.SuhesIsikuElukoht!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesIsikuElukoht))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesIsikuElukoht");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("Suhe.sIsikuStaatus");
                if (clazz.SuhesIsikuStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesIsikuStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesIsikuStaatus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("Suhe.SuhStaatus");
                if (clazz.SuheSuhStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuheSuhStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuheSuhStaatus");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="Suhe.Suhtetyyp") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR84Response>Suhe>Suhe>Suhe.Suhtetyyp");
                    }
                    clazz.SuheSuhtetyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Suhe.Suhtetyyp")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR84Response>Suhe>Suhe>Suhe.Suhtetyyp", Reader.LocalName);
                }
                if (Reader.LocalName=="Suhe.sIsikukood") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR84Response>Suhe>Suhe>Suhe.sIsikukood");
                    }
                    clazz.SuhesIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Suhe.sIsikukood")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR84Response>Suhe>Suhe>Suhe.sIsikukood", Reader.LocalName);
                }
                if (Reader.LocalName=="Suhe.sPerenimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR84Response>Suhe>Suhe>Suhe.sPerenimi");
                    }
                    clazz.SuhesPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Suhe.sPerenimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR84Response>Suhe>Suhe>Suhe.sPerenimi", Reader.LocalName);
                }
                if (Reader.LocalName=="Suhe.sEesnimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR84Response>Suhe>Suhe>Suhe.sEesnimi");
                    }
                    clazz.SuhesEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Suhe.sEesnimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR84Response>Suhe>Suhe>Suhe.sEesnimi", Reader.LocalName);
                }
                if (Reader.LocalName=="Suhe.sIsikuElukoht") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR84Response>Suhe>Suhe>Suhe.sIsikuElukoht");
                    }
                    clazz.SuhesIsikuElukoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Suhe.sIsikuElukoht")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR84Response>Suhe>Suhe>Suhe.sIsikuElukoht", Reader.LocalName);
                }
                if (Reader.LocalName=="Suhe.sIsikuStaatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR84Response>Suhe>Suhe>Suhe.sIsikuStaatus");
                    }
                    clazz.SuhesIsikuStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Suhe.sIsikuStaatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR84Response>Suhe>Suhe>Suhe.sIsikuStaatus", Reader.LocalName);
                }
                if (Reader.LocalName=="Suhe.SuhStaatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR84Response>Suhe>Suhe>Suhe.SuhStaatus");
                    }
                    clazz.SuheSuhStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Suhe.SuhStaatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR84Response>Suhe>Suhe>Suhe.SuhStaatus", Reader.LocalName);
                }
            }
        }
    }
}
